<?php
echo "<pre>";
$dbms = "mysql";
$server = "localhost";
$username = "root";
$password = "";
$dbname = "lx";
$dsn = "$dbms:host=$server;dbname=$dbname";
try{
	$pdo = new PDO ( $dsn, $username, $password);
	echo "PDO连接mysql数据库服务器成功";
	$pre = $pdo->prepare ( "insert into wxf(username, password, email) values (?,?,?)");
	$name = "Peter";
	$pwd = "333333";
	$pre->bindParam ( 1, $name);
	$pre->bindvalue ( 2, $pwd);
	$pre->bindvalue ( 3, "peter@example.com");
	$pre->execute ();
	
	$name = "张三";
	$pre->execute ( array (
	$name,
	"1245",
	"zhangsan@example.com"
	));
	$pre = $pdo->prepare ( "insert into wxf(username, password, email)
	values (:name,:pwd,:email)");
	$name = "老王";
	$pwd = "0054abc";
	$email = "laowang@exmple.com";
	$pre->bindParam ( ":name", $name);
	$pre->bindParam ( ":pwd", $pwd);
	$pre->bindParam ( ":email", $email);
	$pre->execute ();
	$name = "柴可夫斯基";
	$pre->execute ( array (
	":name" => $name,
	":pwd" => "love",
	":email" => "abc@abc.com"
	));
	$pdo = null;
}catch (PDOException $e) {
	echo "PDO连接MYSQL数据库服务器失败";
	die ();
}

?>